<?php
   //第一步：连接数据库
   require 'db_conn.php';//如果这个文件不存在，则程序终止
   //第二步：写查询语句并执行
   $sql="select * from db_employee";
   $rs=$db->query($sql);
   //第三步：处理结果集，取结果集的行数，留言板表有多少条留言
   $num=$rs->num_rows;
   $emp=$rs->fetch_all(MYSQLI_BOTH);
   $rs->free_result();
   $db->close();
?>

<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>2019404129员工管理系统</title>
	<link rel="stylesheet" href="css/bootstrap.css">
	<script src="js/jquery-3.4.1.js"></script>
	<script src="js/bootstrap.js"></script>
	<style>
		#from{padding: 20px;}
#from input{width: 300px;line-height: 25px;}
#style input{width: 50px;}
#sub{text-align: center;margin: 15px 0 0 0;}
	</style>
</head>
<body>
	<div class="container">
		<h1 class="text-center">员工信息列表</h1>
		<table class="table table-bordered table-hover" style="text-align: center;">
			<tr>
				<th>编号</th>
				<th>姓名</th>
				<th>头像</th>
				<th>所属部门</th>
				<th>出生日期</th>
				<th>入职日期</th>
				<th>操作</th>
			</tr>
			<?php foreach ($emp as $v)
			{
				?>
			<tr>
				<td><?php echo $v['id']; ?></td>
				<td><?php echo $v['username']; ?></td>
				<td><img src="<?php echo $v['imgurl']; ?>"></td>
				<td><?php echo $v['dept']; ?></td>
				<td><?php echo $v['m_date']; ?></td>
				<td><?php echo $v['n_date']; ?></td>
				<td>
					<a class="edit_a" href="bbsupdate.php?id=<?php echo $row['id']?>">修改</a>
					<!-- <input type="button" class="btn btn-info" class="edit_a" href="bbsupdate.php?id=<?php echo $row['id']?>" value="编辑" /> -->
					<input type="button" class="btn btn-danger" class="delete" href="javascript:" onclick="if(confirm('确定删除吗？')) 
					location.href='bbsdel.php?id=<?php echo $v['id']?>'" value="删除" />
				</td>
			</tr>
			<?php } ?>
		</table>
	</div>
	<div style="width: 35%;height: auto;background-color: antiquewhite;margin: auto;" id="from">
	<form action="bbsadd.php" method="POST">
	<p>姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：<input type="text" name="username"></p>
	<p>部&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;门：<input type="text" name="dept"></p>
				<p id="style">头&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;像:
				<input type="radio" name="img" value="images/1.jpg" checked="checked" /><img src=" images/1.jpg" alt="" />
				<input type="radio" name="img" value="images/2.jpg" /><img src=" images/2.jpg" alt="" />
				<input type="radio" name="img" value="images/3.jpg" /><img src=" images/3.jpg" alt="" />
				<input type="radio" name="img" value="images/4.jpg" /><img src=" images/4.jpg" alt="" />
			</p>
		<p>出生年月：<input type="date" name='m_date'></p>
		<p>入职时间：<input type="date" name='n_date'></p>
		<p id="sub">
		<button type="submit" class="btn btn-default">保存资料</button>
		<button type="submit" class="btn btn-default">重新填写</button>
	</p>
	</form>
	
</div>
	
</body>
</html>